using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace net.veekee.common.designpattern
{
    [ComVisible(false)]
    [ClassInterface(ClassInterfaceType.None)]
    public class Singleton<T> : IDisposable where T : new()
    {
        protected static T Instance = default(T);
        static readonly object instanceLock = new object();

        public static T GetInstance()
        {
            lock (instanceLock)
            {
                if (Singleton<T>.Instance == null)
                    Singleton<T>.Instance = new T();
                return Singleton<T>.Instance;
            }
        }

        public virtual void Dispose()
        {
        }
    }
}
